﻿using System;
using System.Collections.Generic;
using System.Web;
using Newtonsoft.Json;
using System.Net;
using System.IO;
using System.Xml;

namespace TwentyTree4Umbraco
{
    public class Data
    {
        public string Url { get; set; }

        public Data()
        {
            Url = "http://" + Config.GetSetting("domain");
        }

        public Data(string url)
        {
            Url = url;
        }

       

        public XmlNode GetPhotos()
        {

            WebRequest request = WebRequest.Create(Url + "/js/photos?raw&size=100&p=1");
            try
            {
                WebResponse response = request.GetResponse();
                Stream responseStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(responseStream);

               
                
                XmlNode photos = JsonConvert.DeserializeXmlNode(reader.ReadToEnd(), "TwentyThree");

                response.Close();
                responseStream.Close();

                return photos;
            }
            catch (Exception err)
            {
            }

            return null;
        }

    }
}
